<?php
if (isset($_REQUEST['categoryid'])) {
	$products = ProductController::findAllWithCategoryId($_REQUEST['categoryid']);
}else {
	$products = ProductController::findAll();
}
?>

	<table>
		<tr>
		  <td>
    	    <a href="index_customer.php?action=browse">All</a>
		  </td>
<?php
$arrCategory = CategoryController::findAll();
if(count($arrCategory)>0){
	
	foreach ($arrCategory as $entCategory){
?>
		<td>
		  &nbsp;|&nbsp;
		  <a href="index_customer.php?action=browse&amp;categoryid=<?php print $entCategory->id?>"><?php print $entCategory->name?></a>
		</td>
<?php
	}
}
?>
	</tr>
	</table>	
	<table>
<?php
if (count($products)>0){
	foreach ($products as $p){
	$catids= ProductController::findCategoryIds($p->id);
	$entCategory = CategoryController::find($catids[0]);	
?> 
	  <tr valign="middle">
	    <td colspan="4">
	    	<table>
	    		<tr>
	    			<td>
	    			  <a href="index_customer.php?action=browse">All</a>
	    			  &nbsp;&gt;&nbsp;
	    			  <a href="index_customer.php?action=browse&amp;categoryid=<?php print $entCategory->id?>"><?php print $entCategory->name?></a>
	    			  &nbsp;&gt;&nbsp;<?php print $p->name?>
	    		    </td>
	    		</tr>
		    	<tr>
		    		<td><b>Name:&nbsp;</b><?php print $p->name?></td>
		    	</tr>
		    	<tr>	
				    <td><b>Price:&nbsp;</b><?php print $p->price?>$</td>
		    	</tr>
		    	<tr>	
				    <td><b>Description:&nbsp;</b><?php print $p->desc?></td>
		    	</tr>
	    		<tr>
	    			<td>
					<form action="../<?php echo $www;?>/index_cart.php" method="post">
						<input type="hidden" name="entity" value="customer"/>
						<input type="hidden" name="return" value="browse"/>
						<input type="hidden" name="action" value="add"/>
						<input type="hidden" name="pid" value="<?php print $p->id?>"/>
						<input type="submit" value="request" style="font-size:xx-small;"/>
					</form>	    	
	    			</td>
	    		</tr>
	      	</table>
	    </td>
	    <td>
			<div id="list-img">
				<img width="60%" height="60%" alt="p<?php print $p->id?>.jpeg" src="img/p<?php print $p->id?>.jpeg" />
			</div>  
	    </td>
	  </tr>	    
<?php
	}
}
?> 
	</table>
